package com.subfg.common.constant;

import com.subfg.common.entity.excpetion.BusinessExceptionModel;
import com.subfg.common.util.common.StringUtil;

public enum SupportClientEnum {
    IOS("iOS"),
    IPADOS("iPadOS"),
    ANDROID("Android"),
    WEB("Web"),
    WEBPC("WebPC"),
    APPLET("Applet"),
    SERVER("Server")
    ;
    private String clientName;

    public String getClientName() {
        return clientName;
    }
    /**
     * 构造方法
     * @param clientName    客户端名称
     */
    SupportClientEnum(String clientName) {
        this.clientName = clientName;
    }


    /***
     * 判断将已有客户端是否存在本系统
     * @param clientName    客户端名称
     * @return
     */
    public static SupportClientEnum supportClient(String clientName) {
        if (!StringUtil.isEmpty(clientName)) {
            for (SupportClientEnum clientType : values()) {
                if (clientName.equals(clientType.getClientName())) {
                    return clientType;
                }
            }
        }
        return SupportClientEnum.IOS;
    }


    /**
     * 调用支付时需要进行将android 和 ios 转换成app端
     * @param clientName    客户端名称
     * @return
     */
    public static String transitionClientName(String clientName) {
        if ("Android".equals(clientName) || "iOS".equals(clientName) || "iPadOS".equals(clientName)) {
            return "App";
        }
        return clientName;
    }
}
